package com.ajie.slimming.ui.fragment;

import net.simonvt.numberpicker.NumberPicker;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.ajie.slimming.R;
import com.ajie.slimming.ui.BaseFragment;

/**
 * 控制
 * 
 * @author Jie Liu
 * 
 */
public class ControlFragment extends BaseFragment implements OnClickListener
{
    private NumberPicker partPicker, strengthPicker, timePicker = null;
    
    private Button start;
    
    private String part[], strength[], time[];
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState)
    {
        setTitle(R.string.contorl);
        View view = inflater.inflate(R.layout.fragment_control,
                container,
                false);
        partPicker = (NumberPicker) view.findViewById(R.id.part_chooser);
        strengthPicker = (NumberPicker) view.findViewById(R.id.strenght_chooser);
        timePicker = (NumberPicker) view.findViewById(R.id.time_chooser);
        start = (Button) view.findViewById(R.id.start);
        
        start.setOnClickListener(this);
        
        part = getResources().getStringArray(R.array.part);
        partPicker.setMinValue(0);
        partPicker.setMaxValue(part.length - 1);
        partPicker.setDisplayedValues(part);
        partPicker.setWrapSelectorWheel(true);
        
        strength = getResources().getStringArray(R.array.strength);
        strengthPicker.setMinValue(0);
        strengthPicker.setMaxValue(strength.length - 1);
        strengthPicker.setDisplayedValues(strength);
        strengthPicker.setWrapSelectorWheel(true);
        
        time = getResources().getStringArray(R.array.time);
        timePicker.setMinValue(0);
        timePicker.setMaxValue(time.length - 1);
        timePicker.setDisplayedValues(time);
        timePicker.setWrapSelectorWheel(true);
        return view;
    }
    
    @Override
    public void onClick(View arg0)
    {
        showToast("部位:" + part[partPicker.getValue()] + "\n强度:"
                + strength[strengthPicker.getValue()] + "\n时间:"
                + time[timePicker.getValue()]);
    }
}
